home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / xulrunner / python / compiled_templates / channel.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  48.2 KB  |  733 lines

  1. # This is a generated file. Do not edit.
  2. from template import Handle, fillAttr, quoteAndFillAttr, fillStaticTemplate
  3. from StringIO import StringIO
  4. from xhtmltools import urlencode
  5. from templatehelper import quoteattr, escape
  6. from string import Template
  7. import app
  8. import views
  9. import sorts
  10. import indexes
  11. import filters
  12. import resources
  13. import gtcache
  14. _ = gtcache.gettext
  15. def fillTemplate(domHandler, dtvPlatform, eventCookie, bodyTagExtra, *args, **kargs):
  16.     # Start of handle
  17.  
  18.     # Start user code
  19.     
  20.     #print templateState
  21.     global feed, showDownloads, showWatchableItems, showNewItems, allItemsMode, allItems, watchableItems, matchingItems, newItems, itemSort, itemSortWatchable, itemSortDownloading, notDeleted
  22.     
  23.     def _setFeed(kargs):
  24.         global feed, allItemsMode, showDownloads, showNewItems, showWatchableItems
  25.     
  26.         # The main section
  27.         allItemsMode = False
  28.         
  29.         # Initial states of views in this template
  30.         showDownloads = False
  31.         showNewItems = True
  32.         showWatchableItems = True
  33.     
  34.         feed = views.feeds.getObjectByID(int(kargs['id']))
  35.         filters.switchNewItemsChannel(feed)
  36.         sorts.switchUnwatchedFirstChannel(feed)
  37.     
  38.     def _updateView ():
  39.         global showNewItems, allItemsMode
  40.     
  41.         showNewItems = (len(watchableItems) == 0) or (len(newItems) > 0 and feed.getAutoDownloadMode() == 'off') or feed.getURL().startswith('dtv:directoryfeed')
  42.     
  43.         if len(newItems) == 0 or not showNewItems:
  44.             allItemsMode = True
  45.             matchingItems.recomputeFilter(newItems)
  46.     
  47.         feed.updateIcons()
  48.     
  49.     def reInit(*args, **kargs):
  50.         global feed, allItems, showDownloads, showWatchableItems, showNewItems, allItemsMode, watchableItems, matchingItems, newItems, itemSort, itemSortWatchable, itemSortDownloading
  51.     
  52.         if feed.idExists():
  53.             feed.markAsViewed()
  54.     
  55.         #print "reinitting %s" % repr(kargs)
  56.         _setFeed(kargs)
  57.         itemSort = feed.itemSort
  58.         itemSortDownloading = feed.itemSortDownloading
  59.         itemSortWatchable = feed.itemSortWatchable
  60.         newItems.sortFunc = feed.itemSort.sort
  61.         downloadingItems.sortFunc = feed.itemSortDownloading.sort
  62.         watchableItems.sortFunc = feed.itemSortWatchable.sort
  63.     
  64.         allItems.changeIndexValue(indexes.itemsByFeed, int(kargs['id']))
  65.         views.feeds.recomputeFilter(thisFeedView)
  66.     
  67.         _updateView()
  68.     
  69.     def showDownloadsFilter(x):
  70.         return showDownloads
  71.     
  72.     def showWatchableFilter(x):
  73.         return showWatchableItems
  74.     
  75.     def showNewFilter(x):
  76.         isNew = filters.newItems(x)
  77.         # need to make call newItems() so that the filter remembers if the item
  78.         # was flagged as new or not.
  79.         return showNewItems and (allItemsMode or isNew)
  80.     
  81.     def updateSearchString(newSearch):
  82.         global feed
  83.         if len(newSearch) == 0:
  84.             feed.setInlineSearchTerm(None)
  85.         else:
  86.             feed.setInlineSearchTerm(newSearch)
  87.         allItems.recomputeFilters()
  88.     
  89.     def toggleDownloadsView(handle):
  90.         global showDownloads
  91.         showDownloads = not showDownloads
  92.         allDownloadingItems.recomputeFilter(downloadingItems)
  93.         handle.forceUpdate()
  94.     
  95.     def toggleWatchableView(handle):
  96.         global showWatchableItems
  97.         showWatchableItems = not showWatchableItems
  98.         allWatchableItems.recomputeFilter(watchableItems)
  99.         handle.forceUpdate()
  100.     
  101.     def toggleNewItemsView(handle):
  102.         global showNewItems
  103.         showNewItems = not showNewItems
  104.         matchingItems.recomputeFilter(newItems)
  105.         handle.forceUpdate()
  106.     
  107.     def toggleAllItemsMode(handle):
  108.         global allItemsMode
  109.         allItemsMode = not allItemsMode
  110.         matchingItems.recomputeFilter(newItems)
  111.         handle.forceUpdate()
  112.     
  113.     def setSortBy(by, which, handle):
  114.         if which == 'main':
  115.           feed.itemSort.setSortBy(by)
  116.           matchingItems.recomputeSort(newItems)
  117.         elif which == 'downloading':
  118.           feed.itemSortDownloading.setSortBy(by)
  119.           allDownloadingItems.recomputeSort(downloadingItems)
  120.         else:
  121.           feed.itemSortWatchable.setSortBy(by)
  122.           allWatchableItems.recomputeSort(watchableItems)
  123.         handle.forceUpdate()
  124.     
  125.     _setFeed(kargs)
  126.     
  127.     allItems = views.items.filterWithIndex(indexes.itemsByFeed, feed.getID())
  128.     notDeleted = allItems.filter(filters.notDeleted)
  129.     matchingItems = notDeleted.filter(lambda x: filters.matchingItems(x, feed.inlineSearchTerm))
  130.     newItems = matchingItems.filter(showNewFilter, sortFunc=feed.itemSort.sort, resort=True)
  131.     
  132.     allDownloadingItems = matchingItems.filter(filters.downloadingOrPausedItems)
  133.     downloadingItems = allDownloadingItems.filter(showDownloadsFilter,sortFunc=feed.itemSortDownloading.sort,resort=True)
  134.     allWatchableItems = matchingItems.filter(filters.watchableItems)
  135.     watchableItems = allWatchableItems.filter(showWatchableFilter,sortFunc=feed.itemSortWatchable.sort,resort=True)
  136.     
  137.     thisFeedView = views.feeds.filter(lambda x: x is feed)
  138.     itemSort = feed.itemSort
  139.     itemSortWatchable = feed.itemSortWatchable
  140.     itemSortDownloading = feed.itemSortDownloading
  141.     
  142.     def allItemsHaveState(view, state):
  143.         for item in view:
  144.             if item.getState() != state:
  145.                 return False
  146.         return True
  147.     def allItemsPaused(view):
  148.         return allItemsHaveState(view, 'paused')
  149.     def allItemsDownloading(view):
  150.         return allItemsHaveState(view, 'downloading')
  151.     
  152.     _updateView()
  153.     
  154.     isFolder = False
  155.     
  156.         
  157.  
  158.     def _execOnUnload():
  159.         
  160.         matchingItems.unlink()
  161.         thisFeedView.unlink()
  162.         notDeleted.unlink()
  163.         allItems.unlink()
  164.         if feed.idExists():
  165.             feed.markAsViewed()
  166.         
  167.             
  168.     # End user code
  169.  
  170.     localvars = locals()
  171.     localvars.update(globals())
  172.     handle = Handle(domHandler, localvars, onUnlink = _execOnUnload)
  173.  
  174.     def up_0_handle(viewName, view, tid):
  175.         out = StringIO()
  176.         out.write(u'<div id="')
  177.         out.write(quoteattr(tid))
  178.         out.write(u'">\n    ')
  179.         out.write(u'\n\n<form action="javascript:eventURL(\'template:channel?id=')
  180.         out.write(quoteattr(urlencode(feed.getID())))
  181.         out.write(u'\')" method="GET" name="settings">\n\t<input type="hidden" name="feed" value="')
  182.         out.write(quoteattr(urlencode(feed.getID())))
  183.         out.write(u'"></input>\n\t\n\t<div id="settings-inner">\n            <div id="channel-url">\n                <div class="selectable">')
  184.         out.write(escape(feed.getURL()))
  185.         out.write(u'</div>\n                <div><a href="#" class="remove-channel" onclick="return eventURL(\'action:removeFeed?id=')
  186.         out.write(quoteattr(urlencode(feed.getID())))
  187.         out.write(u'\');"><span>')
  188.         out.write(_(u'remove channel'))
  189.         out.write(u'</span></a></div>\n            </div>\n\t<h2>')
  190.         tmplcomp06199063 = {}
  191.         tmplcomp24115903 = StringIO()
  192.         tmplcomp24115903.write(u'<span>')
  193.         tmplcomp24115903.write(escape(feed.getTitle()))
  194.         tmplcomp24115903.write(u'</span>')
  195.         tmplcomp24115903.seek(0)
  196.         tmplcomp06199063['title'] = tmplcomp24115903.read()
  197.         out.write(Template(_(u'Settings for ${title}')).substitute(tmplcomp06199063))
  198.         out.write(u'</h2> \n\t\t\t\t\n\t\t<div id="actual-settings">\n\t\t\n\t\t<span>')
  199.         out.write(_(u'Videos expire after'))
  200.         out.write(u'</span>\n\t\t<select onChange="javascript:setExpiration();" name="expireAfter">\n\t\t\t')
  201.         if not (feed.getExpirationType() != 'system'):
  202.             out.write(u'<option selected="1" value="system"><span>')
  203.             out.write(_(u'Default'))
  204.             out.write(u'</span> \n(<span>')
  205.             out.write(escape(feed.getFormattedDefaultExpiration()))
  206.             out.write(u'</span>)</option>')
  207.         out.write(u'\n\t\t\t')
  208.         if not (feed.getExpirationType() ==  'system'):
  209.             out.write(u'<option value="system"><span>')
  210.             out.write(_(u'default'))
  211.             out.write(u'</span> (<span>')
  212.             out.write(escape(feed.getFormattedDefaultExpiration()))
  213.             out.write(u'</span>)</option>')
  214.         out.write(u'\n\t\t\t')
  215.         if not (feed.getExpirationTime()  != 3):
  216.             out.write(u'<option selected="1" value="3">3 hours</option>')
  217.         out.write(u'\n\t\t\t')
  218.         if not (feed.getExpirationTime() == 3):
  219.             out.write(u'<option value="3">3 hours</option>')
  220.         out.write(u'\n\t\t\t')
  221.         if not (feed.getExpirationTime() != 24):
  222.             out.write(u'<option selected="1" value="24">1 day</option>')
  223.         out.write(u'\n\t\t\t')
  224.         if not (feed.getExpirationTime() == 24):
  225.             out.write(u'<option value="24">1 day</option>')
  226.         out.write(u'\n\t\t\t')
  227.         if not (feed.getExpirationTime() != 72):
  228.             out.write(u'<option selected="1" value="72">3 days</option>')
  229.         out.write(u'\n\t\t\t')
  230.         if not (feed.getExpirationTime() == 72):
  231.             out.write(u'<option value="72">3 days</option>')
  232.         out.write(u'\n\t\t\t')
  233.         if not (feed.getExpirationTime() != 144):
  234.             out.write(u'<option selected="1" value="144">6 days</option>')
  235.         out.write(u'\n\t\t\t')
  236.         if not (feed.getExpirationTime() == 144):
  237.             out.write(u'<option value="144">6 days</option>')
  238.         out.write(u'\n\t\t\t')
  239.         if not (feed.getExpirationTime() != 240):
  240.             out.write(u'<option selected="1" value="240">10 days</option>')
  241.         out.write(u'\n\t\t\t')
  242.         if not (feed.getExpirationTime() == 240):
  243.             out.write(u'<option value="240">10 days</option>')
  244.         out.write(u'\n\t\t\t')
  245.         if not (feed.getExpirationTime() != 720):
  246.             out.write(u'<option selected="1" value="720">1 month</option>')
  247.         out.write(u'\n\t\t\t')
  248.         if not (feed.getExpirationTime() == 720):
  249.             out.write(u'<option value="720">1 month</option>')
  250.         out.write(u'\n\t\t\t')
  251.         if not (feed.getExpirationType() != 'never'):
  252.             out.write(u'<option selected="1" value="never">Never</option>')
  253.         out.write(u'\n\t\t\t')
  254.         if not (feed.getExpirationType() ==  'never'):
  255.             out.write(u'<option value="never">Never</option>')
  256.         out.write(u'\n\t\t</select>\n<br></br><br></br>\n\t\t')
  257.         if not (feed.getMaxNew() == 'unlimited'):
  258.             out.write(u'<input checked="checked" type="checkbox" name="maxOutDownloads" onClick="javascript:setMaxNew();"></input>')
  259.         out.write(u'\n\t\t')
  260.         if not (feed.getMaxNew() != 'unlimited'):
  261.             out.write(u'<input type="checkbox" name="maxOutDownloads" onClick="javascript:setMaxNew();"></input>')
  262.         out.write(u'\n\t\t<span>')
  263.         tmplcomp34681314 = {}
  264.         tmplcomp81810997 = StringIO()
  265.         if not (feed.getMaxNew() == 'unlimited'):
  266.             tmplcomp81810997.write(u'<input onBlur="javascript:setMaxNew();" name="maxNew" value="')
  267.             tmplcomp81810997.write(quoteattr(urlencode(feed.getMaxNew())))
  268.             tmplcomp81810997.write(u'" type="text" size="3"></input>')
  269.         tmplcomp81810997.seek(0)
  270.         tmplcomp34681314['maxnew2'] = tmplcomp81810997.read()
  271.         tmplcomp07103808 = StringIO()
  272.         if not (feed.getMaxNew() != 'unlimited'):
  273.             tmplcomp07103808.write(u'<input onBlur="javascript:setMaxNew();" name="maxNew" value="3" disabled="1" type="text" size="3"></input>')
  274.         tmplcomp07103808.seek(0)
  275.         tmplcomp34681314['maxnew'] = tmplcomp07103808.read()
  276.         out.write(Template(_(u"Don't Auto Download when more than ${maxnew} ${maxnew2} videos are waiting unwatched.")).substitute(tmplcomp34681314))
  277.         out.write(u'</span><div class="settings-small">')
  278.         out.write(_(u'Prevents this channel from using unlimited disk space.'))
  279.         out.write(u'</div>\n\n\t    <div class="gray-button-wrap settings-button">\n\t\t    <div id="feed-settings-close-button" onclick="return hideSettings()" class="gray-button-bg">\n                <div class="gray-button-left"></div>\n                <div class="gray-button-right"></div>\n                <div class="gray-button-content" i18:translate="">Done</div>\n            </div>\n\t</div>\n \t</div>         \n</div>\n\n\n</form>\n\n')
  280.         out.write(u'\n  </div>')
  281.         out.seek(0)
  282.         return out
  283.     handle.addUpdate('tmplcomp32808340','nextSibling',thisFeedView,up_0_handle, u'thisFeedView')
  284.     def up_1_handle(viewName, view, tid):
  285.         out = StringIO()
  286.         out.write(u'<div id="')
  287.         out.write(quoteattr(tid))
  288.         out.write(u'">\n            <div>\n                <img src="')
  289.         out.write(quoteattr(feed.getThumbnail()))
  290.         out.write(u'" alt="" id="main-icon"></img>\n\t    </div>\n            ')
  291.         if not (feed.getURL().startswith('dtv:directoryfeed')):
  292.             out.write(u'<div class="main-titlebar-right">\n                <ul>\n                    ')
  293.             if not (feed.getLink() == ''):
  294.                 out.write(u'<li>\n                        <a href="')
  295.                 out.write(quoteattr(feed.getLink()))
  296.                 out.write(u'" class="round-button-left black">\n                        <div class="round-button-right black">\n                        <div class="round-button-content black">\n                        <span>')
  297.                 out.write(_(u'VISIT WEBSITE'))
  298.                 out.write(u'</span>\n                        </div>\n                        </div>\n                        </a>\n                    </li>')
  299.             out.write(u'\n                    <li>\n                        <a href="#" class="round-button-left black" onclick="return recommendChannel(\'')
  300.             out.write(quoteattr(urlencode(feed.getTitle())))
  301.             out.write(u"', '")
  302.             out.write(quoteattr(urlencode(feed.getURL())))
  303.             out.write(u'\');">\n                        <div class="round-button-right black">\n                        <div class="round-button-content black">\n                        <span>')
  304.             out.write(_(u'SEND TO FRIEND'))
  305.             out.write(u'</span>\n                        </div>\n                        </div>\n                        </a>\n                    </li>\n                    <li>\n                        <a href="#" class="round-button-left black" onclick="return showSettings();">\n                        <div class="round-button-right black">\n                        <div class="round-button-content black">\n                        <span>')
  306.             out.write(_(u'SETTINGS'))
  307.             out.write(u'</span>\n                        </div>\n                        </div>\n                        </a>\n                    </li>\n                </ul>\n\t    </div>')
  308.         out.write(u'\n        </div>')
  309.         out.seek(0)
  310.         return out
  311.     handle.addUpdate('tmplcomp60523466','nextSibling',thisFeedView,up_1_handle, u'thisFeedView')
  312.     def up_2_handle(viewName, view, tid):
  313.         out = StringIO()
  314.         out.write(u'<div id="')
  315.         out.write(quoteattr(tid))
  316.         out.write(u'">\n            <h1 id="main-title">')
  317.         out.write(escape(feed.getTitle()))
  318.         out.write(u'</h1>\n            <div id="auto-download">\n                ')
  319.         if not (feed.getURL().startswith('dtv:directoryfeed')):
  320.             out.write(u'<div>\n                    <div class="auto-download">\n                        <span id="auto-label">')
  321.             out.write(_(u'AUTO DOWNLOAD'))
  322.             out.write(u'</span>\n                        <div class="select-box-left" onclick="showSelectBoxMenu(\'auto-download-menu\');">\n                        <div class="select-box-right">\n                        ')
  323.             if not (feed is None):
  324.                 out.write(u'<div class="select-box-mid">\n                            <span>')
  325.                 out.write(escape(feed.getAutoDownloadMode()))
  326.                 out.write(u'</span>\n                        </div>')
  327.             out.write(u'\n                        </div>\n                        </div>\n                        \n                        <br clear="all"></br>\n                        ')
  328.             if not (feed is None):
  329.                 out.write(u'<ul id="auto-download-menu" class="select-box-menu">\n                            <li onclick="return eventURL(\'action:setAutoDownloadMode?mode=all&feed=')
  330.                 out.write(quoteattr(urlencode(feed.getID())))
  331.                 out.write(u'\');"><a href="#"><strong>ALL</strong> - Get all videos</a></li>\n                            <li onclick="return eventURL(\'action:setAutoDownloadMode?mode=new&feed=')
  332.                 out.write(quoteattr(urlencode(feed.getID())))
  333.                 out.write(u'\');"><a href="#"><strong>NEW</strong> - Get only new videos</a></li>\n                            <li onclick="return eventURL(\'action:setAutoDownloadMode?mode=off&feed=')
  334.                 out.write(quoteattr(urlencode(feed.getID())))
  335.                 out.write(u'\');"><a href="#"><strong>OFF</strong> - Don\'t auto-download videos</a></li>\n                        </ul>')
  336.             out.write(u'\n                    </div>\n                </div>')
  337.         out.write(u'\n            </div>\n            ')
  338.         if not ('feed' in localvars and feed.getURL() == 'dtv:search'):
  339.             out.write(u'<div id="search-box-container">\n                ')
  340.             if not (not (feed.inlineSearchTerm is None)):
  341.                 out.write(u'<div>\n                    <input value="')
  342.                 out.write(quoteattr(_('Find')))
  343.                 out.write(u'" onfocus="onSearchFocus(this)" type="search" id="search-box" onblur="endEditSearch()"></input>\n                </div>')
  344.             out.write(u'\n                ')
  345.             if not (not (feed.inlineSearchTerm is not None)):
  346.                 out.write(u'<div>\n                    <input onblur="endEditSearch()" searching="1" value="')
  347.                 out.write(quoteattr(feed.inlineSearchTerm))
  348.                 out.write(u'" onfocus="onSearchFocus(this)" type="search" id="search-box"></input>\n                </div>')
  349.             out.write(u'\n            </div>')
  350.         out.write(u'\n            </div>')
  351.         out.seek(0)
  352.         return out
  353.     handle.addUpdate('tmplcomp77257750','nextSibling',thisFeedView,up_2_handle, u'thisFeedView')
  354.     def up_3_handle(viewName, view, tid):
  355.         out = StringIO()
  356.         out.write(u'<div id="')
  357.         out.write(quoteattr(tid))
  358.         out.write(u'">\n            ')
  359.         if not (feed.inlineSearchTerm is None or feed.getURL().startswith('dtv:directoryfeed')):
  360.             out.write(u'<div>\n                <div class="white-button-left save-search-channel">\n                <div class="white-button-right">\n                <div class="white-button-middle">\n                    <a href="#" onclick="return eventURL(\'action:addChannelSearchFeed?id=')
  361.             out.write(quoteattr(urlencode(feed.getID())))
  362.             out.write(u'\');">Save Search</a>\n                </div>\n                </div>\n                </div>\n            </div>')
  363.         out.write(u'\n            </div>')
  364.         out.seek(0)
  365.         return out
  366.     handle.addUpdate('tmplcomp64913735','nextSibling',matchingItems,up_3_handle, u'matchingItems')
  367.     # Start of handle
  368.  
  369.     # Start user code
  370.     # End user code
  371.  
  372.     localvars = locals()
  373.     localvars.update(globals())
  374.     handle_0 = Handle(domHandler, localvars, onUnlink = lambda:None)
  375.  
  376.     handle.addSubHandle(handle_0)
  377.     # Start of handle
  378.  
  379.     # Start user code
  380.     # End user code
  381.  
  382.     localvars = locals()
  383.     localvars.update(globals())
  384.     handle_1 = Handle(domHandler, localvars, onUnlink = lambda:None)
  385.  
  386.     def up_0_handle_1(viewName, view, tid):
  387.         out = StringIO()
  388.         out.write(u'<div id="')
  389.         out.write(quoteattr(tid))
  390.         out.write(u'">\n')
  391.         if not (allDownloadingItems.len() == 0):
  392.             out.write(u'<div>\n<div class="main-channelbar downloading-channelbar" onclick="return eventURL(\'action:toggleDownloadsView\');">\n  ')
  393.             if not (showDownloads):
  394.                 out.write(u'<div class="triangle"></div>')
  395.             out.write(u'\n  ')
  396.             if not (not showDownloads):
  397.                 out.write(u'<div class="triangle down"></div>')
  398.             out.write(u'\n  <a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:cancelDownloads\', event);">Cancel All</a>\n  ')
  399.             if not (allItemsPaused(allDownloadingItems)):
  400.                 out.write(u'<a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:pauseDownloads\', event);">Pause All</a>')
  401.             out.write(u'\n  ')
  402.             if not (allItemsDownloading(allDownloadingItems)):
  403.                 out.write(u'<a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:resumeDownloads\', event);">Resume All</a>')
  404.             out.write(u'\n  ')
  405.             if not (allDownloadingItems.len()==1):
  406.                 out.write(u'<span>\n      <span>')
  407.                 out.write(escape(allDownloadingItems.len()))
  408.                 out.write(u'</span> Downloading</span>')
  409.             out.write(u'\n   ')
  410.             if not (allDownloadingItems.len()!=1):
  411.                 out.write(u'<span>1 Downloading</span>')
  412.             out.write(u'\n</div>\n</div>')
  413.         out.write(u'\n</div>')
  414.         out.seek(0)
  415.         return out
  416.     handle_1.addUpdate('tmplcomp37636645','nextSibling',allDownloadingItems,up_0_handle_1, u'allDownloadingItems')
  417.     def up_1_handle_1(viewName, view, tid):
  418.         out = StringIO()
  419.         out.write(u'<div class="downloading-sort" id="')
  420.         out.write(quoteattr(tid))
  421.         out.write(u'">\n        ')
  422.         if not (downloadingItems.len() == 0):
  423.             out.write(u'<div>\n            ')
  424.             out.write(fillStaticTemplate(u'sort-bar', onlyBody=True, section='downloading', itemSort=itemSortDownloading))
  425.             out.write(u'\n        </div>')
  426.         out.write(u'\n    </div>')
  427.         out.seek(0)
  428.         return out
  429.     handle_1.addUpdate('tmplcomp45286698','nextSibling',downloadingItems,up_1_handle_1, u'downloadingItems')
  430.     def up_2_handle_1(viewName, view, tid):
  431.         out = StringIO()
  432.         out.write(u'<a href="#" class="main-channelbar available-channelbar" onclick="return eventURL(\'action:toggleNewItemsView\');" id="')
  433.         out.write(quoteattr(tid))
  434.         out.write(u'">\n        ')
  435.         if not (showNewItems):
  436.             out.write(u'<div class="triangle"></div>')
  437.         out.write(u'\n        ')
  438.         if not (not showNewItems):
  439.             out.write(u'<div class="triangle down"></div>')
  440.         out.write(u'\n\n        ')
  441.         if not (not (not isFolder)):
  442.             out.write(u'<div>\n            ')
  443.             if not (not (feed.inlineSearchTerm is None)):
  444.                 out.write(u'<div>\n                <span>')
  445.                 out.write(escape(notDeleted.len()))
  446.                 out.write(u'</span> \n                Items in this Channel\n            </div>')
  447.             out.write(u'\n            ')
  448.             if not (not (feed.inlineSearchTerm is not None)):
  449.                 out.write(u'<div>\n                ')
  450.                 if not (not (notDeleted.len() == matchingItems.len())):
  451.                     out.write(u'<div>\n                    All <span>')
  452.                     out.write(escape(matchingItems.len()))
  453.                     out.write(u'</span> \n                    Match This Search\n                </div>')
  454.                 out.write(u'\n                ')
  455.                 if not (notDeleted.len() == matchingItems.len()):
  456.                     out.write(u'<div>\n                    <span>')
  457.                     out.write(escape(matchingItems.len()))
  458.                     out.write(u'</span> \n                    Match This Search\n                </div>')
  459.                 out.write(u'\n            </div>')
  460.             out.write(u'\n        </div>')
  461.         out.write(u'\n\n        ')
  462.         if not (not (isFolder)):
  463.             out.write(u'<div>\n            <span>')
  464.             out.write(escape(notDeleted.len()))
  465.             out.write(u'</span> \n            Items in this Channel Folder\n        </div>')
  466.         out.write(u'\n    </a>')
  467.         out.seek(0)
  468.         return out
  469.     handle_1.addUpdate('tmplcomp60446172','nextSibling',matchingItems,up_2_handle_1, u'matchingItems')
  470.     def up_3_handle_1(viewName, view, tid):
  471.         out = StringIO()
  472.         out.write(u'<div id="')
  473.         out.write(quoteattr(tid))
  474.         out.write(u'">\n    ')
  475.         if not (not (showNewItems)):
  476.             out.write(u'<div class="available-sort">\n        ')
  477.             out.write(fillStaticTemplate(u'sort-bar', onlyBody=True, section='main', itemSort=itemSort))
  478.             out.write(u'\n    </div>')
  479.         out.write(u'\n</div>')
  480.         out.seek(0)
  481.         return out
  482.     handle_1.addUpdate('tmplcomp11022004','nextSibling',matchingItems,up_3_handle_1, u'matchingItems')
  483.     def up_4_handle_1(viewName, view, tid):
  484.         out = StringIO()
  485.         out.write(u'<div id="')
  486.         out.write(quoteattr(tid))
  487.         out.write(u'">  \n  ')
  488.         if not (allItemsMode or not showNewItems or newItems.len() == matchingItems.len()):
  489.             out.write(u'<div>\n      <a href="#" class="main-notification" onclick="return eventURL(\'action:toggleAllItemsMode\');">\n          ')
  490.             if not (isFolder):
  491.                 out.write(u'<span><span>')
  492.                 out.write(escape(matchingItems.len() - newItems.len()))
  493.                 out.write(u'</span> more on this channel >></span>')
  494.             out.write(u'\n          ')
  495.             if not (not (isFolder)):
  496.                 out.write(u'<span><span>')
  497.                 out.write(escape(matchingItems.len()))
  498.                 out.write(u'</span> items in this channel folder >></span>')
  499.             out.write(u'\n        </a>\n        <a href="#" class="main-notification-right" onclick="return eventURL(\'action:toggleAllItemsMode\');"> </a>\n     <br clear="left"></br>\n  </div>')
  500.         out.write(u'\n</div>')
  501.         out.seek(0)
  502.         return out
  503.     handle_1.addUpdate('tmplcomp54166034','nextSibling',matchingItems,up_4_handle_1, u'matchingItems')
  504.     def up_5_handle_1(viewName, view, tid):
  505.         out = StringIO()
  506.         out.write(u'<div id="')
  507.         out.write(quoteattr(tid))
  508.         out.write(u'">\n        ')
  509.         if not (len(allWatchableItems) == 0 or (not isFolder and feed.getURL().startswith('dtv:directoryfeed'))):
  510.             out.write(u'<a href="#" class="main-channelbar downloaded-channelbar" onclick="return eventURL(\'action:toggleWatchableView\')">\n            ')
  511.             if not (showWatchableItems):
  512.                 out.write(u'<div class="triangle"></div>')
  513.             out.write(u'\n            ')
  514.             if not (not showWatchableItems):
  515.                 out.write(u'<div class="triangle down"></div>')
  516.             out.write(u'\n            <span>')
  517.             tmplcomp01194628 = {}
  518.             tmplcomp98649693 = StringIO()
  519.             tmplcomp98649693.write(u'<span>')
  520.             tmplcomp98649693.write(escape(allWatchableItems.len()))
  521.             tmplcomp98649693.write(u'</span>')
  522.             tmplcomp98649693.seek(0)
  523.             tmplcomp01194628['len'] = tmplcomp98649693.read()
  524.             out.write(Template(_(u'${len} Downloaded')).substitute(tmplcomp01194628))
  525.             out.write(u'</span>\n        </a>')
  526.         out.write(u'\n    </div>')
  527.         out.seek(0)
  528.         return out
  529.     handle_1.addUpdate('tmplcomp46742417','nextSibling',allWatchableItems,up_5_handle_1, u'allWatchableItems')
  530.     def up_6_handle_1(viewName, view, tid):
  531.         out = StringIO()
  532.         out.write(u'<div id="')
  533.         out.write(quoteattr(tid))
  534.         out.write(u'">\n        ')
  535.         if not (len(watchableItems) == 0):
  536.             out.write(u'<div>\n            ')
  537.             out.write(fillStaticTemplate(u'sort-bar', onlyBody=True, section='watchable', itemSort=itemSortWatchable))
  538.             out.write(u'\n        </div>')
  539.         out.write(u'\n    </div>')
  540.         out.seek(0)
  541.         return out
  542.     handle_1.addUpdate('tmplcomp31872732','nextSibling',watchableItems,up_6_handle_1, u'watchableItems')
  543.     def rep_7_handle_1(this, viewName, view, tid):
  544.         out = StringIO()
  545.         out.write(u'\n<div dragsourcetype="')
  546.         out.write(quoteattr(this.getDragType()))
  547.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  548.         out.write(quoteattr(this.getID()))
  549.         out.write(u'" dragicon="video-tnail-')
  550.         out.write(quoteattr(viewName + str(this.getID())))
  551.         out.write(u'" selectID="')
  552.         out.write(quoteattr(this.getID()))
  553.         out.write(u'" class="main-video draggable ')
  554.         out.write(quoteattr(this.getSelectedState(view)))
  555.         out.write(u' ')
  556.         out.write(quoteattr(this.getMoreInfoState()))
  557.         out.write(u'" dragsourcedata="itemlist-')
  558.         out.write(quoteattr(this.getID()))
  559.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  560.         out.write(quoteattr(urlencode(viewName)))
  561.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  562.         out.write(quoteattr(viewName == 'playlistView' and 'downloadeditem' or ''))
  563.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  564.         out.write(quoteattr(urlencode(viewName)))
  565.         out.write(u"', ")
  566.         out.write(quoteattr(urlencode(this.getID())))
  567.         out.write(u');" id="')
  568.         out.write(quoteattr(tid))
  569.         out.write(u'">\n    <div>')
  570.         out.write(this.getItemXML(viewName))
  571.         out.write(u'</div>\n</div>\n')
  572.         out.seek(0)
  573.         return out
  574.     handle_1.addView('tmplcomp48244590','containerDiv',downloadingItems,rep_7_handle_1, u'downloadingItems')
  575.     def rep_8_handle_1(this, viewName, view, tid):
  576.         out = StringIO()
  577.         out.write(u'\n<div dragsourcetype="')
  578.         out.write(quoteattr(this.getDragType()))
  579.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  580.         out.write(quoteattr(this.getID()))
  581.         out.write(u'" dragicon="video-tnail-')
  582.         out.write(quoteattr(viewName + str(this.getID())))
  583.         out.write(u'" selectID="')
  584.         out.write(quoteattr(this.getID()))
  585.         out.write(u'" class="main-video draggable ')
  586.         out.write(quoteattr(this.getSelectedState(view)))
  587.         out.write(u' ')
  588.         out.write(quoteattr(this.getMoreInfoState()))
  589.         out.write(u'" dragsourcedata="itemlist-')
  590.         out.write(quoteattr(this.getID()))
  591.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  592.         out.write(quoteattr(urlencode(viewName)))
  593.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  594.         out.write(quoteattr(viewName == 'playlistView' and 'downloadeditem' or ''))
  595.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  596.         out.write(quoteattr(urlencode(viewName)))
  597.         out.write(u"', ")
  598.         out.write(quoteattr(urlencode(this.getID())))
  599.         out.write(u');" id="')
  600.         out.write(quoteattr(tid))
  601.         out.write(u'">\n    <div>')
  602.         out.write(this.getItemXML(viewName))
  603.         out.write(u'</div>\n</div>\n')
  604.         out.seek(0)
  605.         return out
  606.     handle_1.addView('tmplcomp61348099','containerDiv',newItems,rep_8_handle_1, u'newItems')
  607.     def rep_9_handle_1(this, viewName, view, tid):
  608.         out = StringIO()
  609.         out.write(u'\n<div dragsourcetype="')
  610.         out.write(quoteattr(this.getDragType()))
  611.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  612.         out.write(quoteattr(this.getID()))
  613.         out.write(u'" dragicon="video-tnail-')
  614.         out.write(quoteattr(viewName + str(this.getID())))
  615.         out.write(u'" selectID="')
  616.         out.write(quoteattr(this.getID()))
  617.         out.write(u'" class="main-video draggable ')
  618.         out.write(quoteattr(this.getSelectedState(view)))
  619.         out.write(u' ')
  620.         out.write(quoteattr(this.getMoreInfoState()))
  621.         out.write(u'" dragsourcedata="itemlist-')
  622.         out.write(quoteattr(this.getID()))
  623.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  624.         out.write(quoteattr(urlencode(viewName)))
  625.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  626.         out.write(quoteattr(viewName == 'playlistView' and 'downloadeditem' or ''))
  627.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  628.         out.write(quoteattr(urlencode(viewName)))
  629.         out.write(u"', ")
  630.         out.write(quoteattr(urlencode(this.getID())))
  631.         out.write(u');" id="')
  632.         out.write(quoteattr(tid))
  633.         out.write(u'">\n    <div>')
  634.         out.write(this.getItemXML(viewName))
  635.         out.write(u'</div>\n</div>\n')
  636.         out.seek(0)
  637.         return out
  638.     handle_1.addView('tmplcomp96811263','containerDiv',watchableItems,rep_9_handle_1, u'watchableItems')
  639.     # Start of handle
  640.  
  641.     # Start user code
  642.     # End user code
  643.  
  644.     localvars = locals()
  645.     localvars.update(globals())
  646.     handle_1_0 = Handle(domHandler, localvars, onUnlink = lambda:None)
  647.  
  648.     handle_1.addSubHandle(handle_1_0)
  649.     # Start of handle
  650.  
  651.     # Start user code
  652.     # End user code
  653.  
  654.     localvars = locals()
  655.     localvars.update(globals())
  656.     handle_1_1 = Handle(domHandler, localvars, onUnlink = lambda:None)
  657.  
  658.     handle_1.addSubHandle(handle_1_1)
  659.     # Start of handle
  660.  
  661.     # Start user code
  662.     # End user code
  663.  
  664.     localvars = locals()
  665.     localvars.update(globals())
  666.     handle_1_2 = Handle(domHandler, localvars, onUnlink = lambda:None)
  667.  
  668.     handle_1.addSubHandle(handle_1_2)
  669.     handle.addSubHandle(handle_1)
  670.  
  671.  
  672.     out = StringIO()
  673.     out.write(u"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n")
  674.     out.write(u'<html dtvPlatform="')
  675.     out.write(quoteattr(urlencode(dtvPlatform)))
  676.     out.write(u'" eventCookie="')
  677.     out.write(quoteattr(urlencode(eventCookie)))
  678.     out.write(u'" xmlns="http://www.w3.org/1999/xhtml">\n\n<head>\n    <base href="')
  679.     out.write(quoteattr(feed.getBaseHref()))
  680.     out.write(u'"></base>\n    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta>\n    <title>Miro Channel View</title>\n\n    <link href="')
  681.     out.write(quoteattr(resources.url(u'css/main.css')))
  682.     out.write(u'" type="text/css" rel="stylesheet"></link>\n    <script type="text/javascript">\n<!-- // Protect from our XML parser, which doesn\'t know to protect <script>\n\n///////////////////////////////////////////////////////////////////////////////\n//// For use on your page                                                  ////\n///////////////////////////////////////////////////////////////////////////////\n\nfunction getDTVPlatform() {\n    var elt = document.getElementsByTagName("html")[0];\n    return elt.getAttribute(\'dtvPlatform\');\n}\n\nfunction loadURL(url) {\n    try {\n        document.location.href = url;\n    } catch (e) {\n        // This may happen if the backend decides to handle the url load\n        // itself.\n    }\n}\n\n// For calling from page Javascript: Cause a URL to be loaded. The\n// assumption is that the application will notice, abort the load, and\n// take some action based on the URL.\nfunction eventURL(url) {\n    if (typeof(window.frontend) == \'undefined\') {\n\t// Generic strategy: trigger a load, and hope the application\n\t// catches it and cancels it without creating a race\n\t// condition.\n        loadURL(url)\n    } else {\n\t// OS X WebKit (KHTML) strategy: pass in an Objective C object\n\t// through the window object and call a method on it.\n\twindow.frontend.eventURL(url);\n    }\n\n    return false;\n}\n\n// Calls eventURL, then calls event.stopPropagation() and\n// event.preventDefault() so that the event chain is stopped.\nfunction eventURLAndStop(url, event) {\n  eventURL(url);\n  event.stopPropagation();\n  event.preventDefault();\n}\n\nfunction recommendItem(title, url) {\n    loadURL(\'http://www.videobomb.com/index/democracyemail?url=\' + \n            url + \'&title=\' + title);\n    return false;\n}\n\nfunction recommendChannel(title, url) {\n    // See also app.py if changing this URL\n    loadURL(\'http://www.videobomb.com/democracy_channel/email_friend\' +\n        \'?url=\' + url + \'&title=\' + title);\n    return false;\n}\n\n// Start the video player. The playlist will be the items in the view\n// named by viewName. If firstItemId is the id of an item in the view,\n// playback will start on that item; otherwise playback will start on\n// the first item.\nfunction playViewNamed(viewName, firstItemId) {\n    url = \'action:playViewNamed?\';\n    url = url + \'viewName=\' + URLencode(viewName);\n    url = url + \'&firstItemId=\' + URLencode(firstItemId);\n    eventURL(url);\n    return false;\n}\n\n// You can make \'incremental search\' text boxes on your page that\n// effectively tie the text box to the \'parameter\' argument of setViewFilter,\n// with the other argumens fixed. To do this, add these two attributes to\n// the text box:\n//   onfocus="startEditSearch(this)"\n//   onblur="endEditFilter()"\n// replacing the arguments in parentheses with the desired strings.\n//\n// You\'ll also need to provide a updateSearchString function at the\n// top of your template to perform the actual update\n\nvar editSearchField = null;\nvar editSearchOldValue = \'\';\nvar editSearchTimer = null;\nvar editSearchCallback = null;\n\nfunction onSearchFocus(obj){\n  if (obj.getAttribute(\'searching\') != \'1\') {\n\tobj.value="";\n\tobj.searching = \'1\';\n  }\n  startEditSearch(obj, null);\n}\n\nfunction startEditSearch(obj, callback) {\n  editSearchOldValue = obj.value;\n\n  editSearchField = obj;\n  editSearchCallback = callback;\n  editSearchTimerTick();\n}\n\nfunction editSearchUpdate() {\n    value = editSearchField.value;\n    if (editSearchOldValue != value) {\n\turl = \'action:setSearchString?searchString=\' + URLencode(value);\n\teventURL(url);\n\teditSearchOldValue = value;\n\tif(editSearchCallback) editSearchCallback();\n    }\n}\n\nfunction editSearchTimerTick() {\n    editSearchUpdate();\n    editSearchTimer = setTimeout(editSearchTimerTick, 50);\n}\n\nfunction endEditSearch() {\n  clearTimeout(editSearchTimer);\n  editSearchUpdate();\n}\n\n// Internal use: \'URL encode\' the given string.\nfunction URLencode(str) {\n    return encodeURIComponent(str)\n}\n\nfunction URLdecode(str) {\n  return decodeURIComponent(str)\n}\n\nvar currentSelectBoxMenu = null;\nfunction showSelectBoxMenu(id) {\n    document.getElementById(id).style.display = \'block\';\n    currentSelectBoxMenu = id;\n    document.addEventListener(\'click\', hideSelectBoxMenu, true)\n}\n\nfunction hideSelectBoxMenu(event) {\n    document.getElementById(currentSelectBoxMenu).style.display = \'\';\n    currentSelectBoxMenu = null;\n    document.removeEventListener(\'click\', hideSelectBoxMenu, true)\n}\n\n///////////////////////////////////////////////////////////////////////////////\n//// For calling by host templating code                                   ////\n///////////////////////////////////////////////////////////////////////////////\n\n// For calling by host templating code: Set CSS styles on the item\n// with the given ID to make it disappear.\nfunction hideItem(id) {\n    elt = document.getElementById(id);\n    elt.style.display = \'none\';\n    forceRedisplay(elt);\n}\n\n// For calling by host templating code: Set CSS styles on the item\n// with the given ID to make it visible if it was previously hidden.\nfunction showItem(id) {\n    elt = document.getElementById(id);\n    elt.style.display = \'\';\n    forceRedisplay(elt);\n}\n\n// For calling by host templating code: Replace the item with the\n// given id with the element described by the proided XML.\nfunction changeItem(id, newXML) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.parentNode.replaceChild(frag, elt);\n}\n\n// For calling by host templating code: Parse the XML in newXML into a\n// new element, and insert the new element immediately before the item\n// with the given id, such that the newly inserted item has the same\n// parent.\nfunction addItemBefore(newXML, id) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.parentNode.insertBefore(frag, elt);\n}    \n\n// For calling by host templating code: Parse the XML in newXML into a\n// new element, and insert the new element as the final child of the\n// item with the given id.\nfunction addItemAtEnd(newXML, id) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.insertBefore(frag, null);\n}    \n\n// For calling by host templating code: Remove the item with the given\n// id.\nfunction removeItem(id) {\n    elt = document.getElementById(id);\n    elt.parentNode.removeChild(elt);\n}    \n\n// Internal use: Sometime if all you do is change the style on a node,\n// Safari doesn\'t update the view until your mouse is next over the\n// window. Force the issue by making a drastic change in the vicinity\n// of the given element and then reversing it.\nfunction forceRedisplay(elt) {\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.extractContents();\n    r.insertNode(frag);\n}\n\nfunction handleContextMenuSelect(event) {\n  if(event.button == 2) {\n    var area = event.currentTarget.getAttribute("selectArea");\n    var id = event.currentTarget.getAttribute("selectID");\n    var viewName = event.currentTarget.getAttribute("selectViewName");\n    var url = \'action:handleContextMenuSelect?id=\' + id + \'&area=\' + area +\n              \'&viewName=\' + viewName;\n    eventURL(url);\n  }\n  return true;\n}\n\nfunction handleSelect(event) {\n   if(event.target.tagName && event.target.tagName.toUpperCase() == \'A\') {\n       // Either a link in the descrption, or a bomb/mailto/trash click\n       return true;\n    }\n    var id = event.currentTarget.getAttribute("selectID");\n    var viewName = event.currentTarget.getAttribute("selectViewName");\n    var area = event.currentTarget.getAttribute("selectArea");\n    var shiftKey = \'0\';\n    var ctrlKey = \'0\';\n    if(event.shiftKey) shiftKey = \'1\';\n    if(event.ctrlKey || event.metaKey) ctrlKey = \'1\';\n    eventURL(\'action:handleSelect?area=\' + area + \'&viewName=\' + viewName + \n\t\'&id=\' + id + \'&shiftDown=\' + shiftKey + \'&ctrlDown=\' + ctrlKey);\n    return true;\n}\n\nfunction handleDblClick(event, viewName, id) {\n   var target = event.target;\n   while (target != undefined && target.ondblclick === null && target.tagName.toUpperCase() != \'A\') {\n       target = target.parentNode;\n   }\n\n   if(target.tagName.toUpperCase() == \'A\') {\n       // Either a link in the descrption, or a bomb/mailto/trash click\n       return true;\n   } else {\n       return eventURL(\'action:playViewNamed?viewName=\' + viewName + \n           \'&firstItemId=\' + id);\n   }\n}\n\nfunction getKeyFromEvent(evt) {\n  var key = 0;\n  if (window.event)  {\n    key = evt.keyCode;\n  } else if (evt.which) {\n  \tkey = evt.which;\n  }\n\n  return key;\n}\n\nfunction sendKeyToSearchBox(event) {\n  if(event.altKey || event.ctrlKey || event.metaKey ||\n      (event.target.tagName && event.target.tagName.toUpperCase() == \'INPUT\'))\n      return true;\n  var key = getKeyFromEvent(event);\n  if ((key == 33) || (key == 34) || (key == 35) || (key == 36) || \n      (key == 37) || (key == 38) || (key == 39) || (key == 40))\n      return true;\n  var searchBox = document.getElementById("search-box");\n  searchBox.focus();\n  return true;\n}\n\nfunction playNewVideos(event, id) {\n  eventURL(\'action:playNewVideos?id=\' + id);\n  event.stopPropagation(); // don\'t want handleSelect to deal with this event\n  return false;\n}\n\n///////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////\n\n-->\n</script>\n\n    <script type="text/javascript">\n    <!-- // Protect from our XML parser, which doesn\'t know to protect <script>\n\n    var settingsMode = \'closed\';\n\n    function showSettings()\n    {\n        if(settingsMode == \'open\') return hideSettings();\n        var feedSettings = document.getElementById("feed-settings");\n        feedSettings.style.display = "block";\n        settingsMode = \'open\';\n        return false;\n    }\n\n    function hideSettings()\n    {\n        var feedSettings = document.getElementById("feed-settings");\n        feedSettings.style.display = "none";\n        settingsMode = \'closed\';\n        return false;\n    }\n\n    function setExpiration()\n    {\n        var url = "action:setExpiration";\n        var idx = document.forms[\'settings\'][\'expireAfter\'].selectedIndex;\n        var value = document.forms[\'settings\'][\'expireAfter\'].options[idx].value;\n\n        url += \'?feed=\' + document.forms[\'settings\'][\'feed\'].value;\n        if (value == \'system\' || value == \'never\')\n        {\n            url += "&type=" + value + "&time=0";\n        }\n        else\n        {\n            url += "&type=feed&time=" + value;\n        }\n\n        eventURL(url);\n    }\n\n    function setMaxNew()\n    {\n        var url = "action:setMaxNew";\n\n        url += \'?feed=\' + document.forms[\'settings\'][\'feed\'].value;\n        if (document.forms[\'settings\'][\'maxOutDownloads\'].checked)\n        {\n            var maxNew = document.forms[\'settings\'][\'maxNew\'];\n            maxNew.disabled = false;\n            if(maxNew.value == \'\') maxNew.value = \'0\';\n            if(!(parseInt(maxNew.value) >= 0)) {\n               eventURL(\'action:invalidMaxNew?value=\' + escape(maxNew.value));\n               maxNew.value = \'0\';\n            }\n            url += \'&maxNew=\' + maxNew.value;\n        }\n        else\n        {\n            document.forms[\'settings\'][\'maxNew\'].disabled = true;\n            url += \'&maxNew=-1\';\n        }\n\n        eventURL(url);\n    }\n\n    -->\n</script>\n\n    <script src="')
  683.     out.write(quoteattr(resources.url(u'templates/osxdnd.js')))
  684.     out.write(u'" type="text/javascript"></script>\n    \n    \n\n</head>\n\n<body onkeydown="sendKeyToSearchBox(event);"')
  685.     out.write(u" " + bodyTagExtra)
  686.     out.write(u'>\n<div id="feed-settings">\n  ')
  687.     out.write(u'<span id="tmplcomp32808340"/>\n</div>\n    \n\n\n<div id="main-titlebar">\n        ')
  688.     out.write(u'<span id="tmplcomp60523466"/>\n\n        <div class="main-titlebar-left">\n            ')
  689.     out.write(u'<span id="tmplcomp77257750"/>\n            ')
  690.     out.write(u'<span id="tmplcomp64913735"/>\n        </div>\n</div>\n\n\n\n<div id="main-container">\n    <div t:showIf=')
  691.     out.write(quoteAndFillAttr(u'feed.isScraped() and feed.isUpdating()',locals()))
  692.     out.write(u' class=')
  693.     out.write(quoteAndFillAttr(u'main-container-scraping',locals()))
  694.     out.write(u' id="tmplcomp40028358"')
  695.     _hideFunc = lambda : not (feed.isScraped() and feed.isUpdating())
  696.     _dynHide = _hideFunc()
  697.     if _dynHide:
  698.         out.write(u" style=\"display:none\">")
  699.     else:
  700.         out.write(u">")
  701.     handle.addUpdateHideOnView('tmplcomp40028358',thisFeedView,_hideFunc,_dynHide)
  702.     out.write(u'\n    <div class="scraping-indicator">\n      <img src="')
  703.     out.write(quoteattr(resources.url(u'images/scraping-indicator-left.gif')))
  704.     out.write(u'" align="left"></img>\n      <img src="')
  705.     out.write(quoteattr(resources.url(u'images/scraping-indicator-right.gif')))
  706.     out.write(u'" align="right"></img>\n      <div class="scraping-content">')
  707.     out.write(_(u'Looking for videos at this URL'))
  708.     out.write(u'</div>\n    </div>\n    </div>\n    <div class="hide-channel-title">\n        ')
  709.     out.write(u'\n\n')
  710.     out.write(u'<span id="tmplcomp37636645"/>\n\n    ')
  711.     out.write(u'<span id="tmplcomp45286698"/>\n    <div id="tmplcomp48244590">')
  712.     out.write(u'</div>\n\n\n\n\n\n<div class="available-channelbar-wrap">\n    ')
  713.     out.write(u'<span id="tmplcomp60446172"/>\n</div>\n\n')
  714.     out.write(u'<span id="tmplcomp11022004"/>\n\n<div id="tmplcomp61348099">')
  715.     out.write(u'</div>\n\n\n')
  716.     out.write(u'<span id="tmplcomp54166034"/>\n\n\n\n\n<div id="tmplcomp09684708"')
  717.     _hideFunc = lambda : not isFolder and feed.getURL().startswith('dtv:directoryfeed')
  718.     _dynHide = _hideFunc()
  719.     if _dynHide:
  720.         out.write(u" style=\"display:none\">")
  721.     else:
  722.         out.write(u">")
  723.     handle.addUpdateHideOnView('tmplcomp09684708',thisFeedView,_hideFunc,_dynHide)
  724.     out.write(u'\n    ')
  725.     out.write(u'<span id="tmplcomp46742417"/>\n    \n    ')
  726.     out.write(u'<span id="tmplcomp31872732"/>\n    <div id="tmplcomp96811263">')
  727.     out.write(u'</div>\n</div>\n\n\n')
  728.     out.write(u'\n    </div>\n</div>\n\n\n</body>\n</html>')
  729.     out.seek(0)
  730.  
  731.  
  732.     return (out, handle)
  733.